import type {
  PersonalTagForm,
  PersonalTagGroupForm,
  PersonalTagGroupQuery,
  PersonalTagGroupVO,
  PersonalTagQuery,
  PersonalTagVO,
} from './model';

import type { ID, IDS, PageResult } from '#/api/common';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

/**
 * 查询公司标签组列表 - 不分页
 * @param params
 * @returns 公司标签组列表
 */
export function personalTagGroupList(params?: PersonalTagGroupQuery) {
  return requestClient.get<PersonalTagGroupVO[]>('/employee/label/group/list', {
    params,
  });
}

/**
 * 查询公司标签组详情
 * @param id id
 * @returns 公司标签组详情
 */
export function personalTagGroupInfo(id: ID) {
  return requestClient.get<PersonalTagGroupVO>(`/employee/label/group/${id}`);
}

/**
 * 新增公司标签组
 * @param data
 * @returns void
 */
export function personalTagGroupAdd(data: PersonalTagGroupForm) {
  return requestClient.postWithMsg<void>('/employee/label/group', data);
}

/**
 * 更新公司标签组
 * @param data
 * @returns void
 */
export function personalTagGroupUpdate(data: PersonalTagGroupForm) {
  return requestClient.putWithMsg<void>('/employee/label/group', data);
}

/**
 * 删除公司标签组
 * @param id id
 * @returns void
 */
export function personalTagGroupRemove(id: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/employee/label/group/${id}`);
}

/**
 * 修改标签组状态
 * @param data
 */
export function personalTagGroupChangeStatus(
  data: Partial<PersonalTagGroupVO>,
) {
  const requestData = {
    id: data.id,
    status: data.status,
  };
  return requestClient.putWithMsg<void>(
    `/employee/label/group/changeStatus`,
    requestData,
  );
}

/**
 * 分页查询企业标签列表
 * @param params
 * @returns 企业标签列表
 */
export function personalTagPage(params?: PersonalTagQuery) {
  return requestClient.get<PageResult<PersonalTagVO>>('/employee/label/page', {
    params,
  });
}

/**
 * 查询企业标签列表
 * @param params
 * @returns 企业标签列表
 */
export function personalTagList(params?: PersonalTagQuery) {
  return requestClient.get<PersonalTagVO[]>('/employee/label/list', {
    params,
  });
}

/**
 * 导出企业标签列表
 * @param params
 * @returns 企业标签列表
 */
export function personalTagExport(params?: PersonalTagQuery) {
  return commonExport('/employee/label/export', params ?? {});
}

/**
 * 查询企业标签详情
 * @param id id
 * @returns 企业标签详情
 */
export function personalTagInfo(id: ID) {
  return requestClient.get<PersonalTagVO>(`/employee/label/${id}`);
}

/**
 * 新增企业标签
 * @param data
 * @returns void
 */
export function personalTagAdd(data: PersonalTagForm) {
  return requestClient.postWithMsg<void>('/employee/label', data);
}

/**
 * 更新企业标签
 * @param data
 * @returns void
 */
export function personalTagUpdate(data: PersonalTagForm) {
  return requestClient.putWithMsg<void>('/employee/label', data);
}

/**
 * 删除企业标签
 * @param id id
 * @returns void
 */
export function personalTagRemove(id: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/employee/label/${id}`);
}

/**
 * 批量修改标签排序
 * @param tagList
 */
export function personalTagChangeSort(tagList: PersonalTagVO[]) {
  return requestClient.postWithMsg<void>(`/employee/label/changeSort`, tagList);
}

/**
 * 修改标签状态
 * @param data
 */
export function personalTagChangeStatus(data: Partial<PersonalTagVO>) {
  const requestData = {
    id: data.id,
    status: data.status,
  };
  return requestClient.putWithMsg<void>(
    `/employee/label/changeStatus`,
    requestData,
  );
}
